<?php 
use com\soka\SokaModel;

class Concepto_Mdl extends SokaModel
{
	//private $dinamic;
	public function get($name_where) {
		try {
	        $result = $this->_db->prepare("SELECT c.* ,tp.nombre as tipoconcepto FROM concepto c INNER JOIN tipoconcepto tp ON c.tipoconcepto_id=tp.id ".$name_where."");
	        $result->execute();
	        while ($row = $result->fetch(\PDO::FETCH_ASSOC))
	        {
				$data[] = $row;
	        }
        } catch (\PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
        	die();
        }
        return $data;
	}

	public function get_concepto() {
		try {
	        $result = $this->_db->prepare("CALL sp_valor_concepto()");
	        $result->execute();
	        while ($row = $result->fetch(\PDO::FETCH_OBJ))
	        {
				$data[$row->nombre][$row->concepto]= $row->valor;
	        }
        } catch (\PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
        	die();
        }
        return $data;		
	}

	public function value($tipo = null, $name_con) {
		$val = $this->get_concepto();
		return $val [$tipo] [$name_con];       	
	}
}